// IBackend.aidl
package com.fanwj.citrus.aidl;

interface IBackend {

    @Backing(type="int")
    enum ControllerType {
        ProController,
        DualJoyconDetached,
        LeftJoycon,
        RightJoycon,
        Handheld,
        GameCube,
        Pokeball,
        NES,
        SNES,
        N64,
        SegaGenesis,
    }

    @Backing(type="int")
    enum PatchType {
        Update,
        DLC,
        Mod
    }

    @Backing(type="int")
    enum NativeButton {
        A,
        B,
        X,
        Y,
        LStick,
        RStick,
        L,
        R,
        ZL,
        ZR,
        Plus,
        Minus,
        DLeft,
        DUp,
        DRight,
        DDown,
        SLLeft,
        SRLeft,
        Home,
        Screenshot,
        SLRight,
        SRRight,
        NumButtons,
    }

    @Backing(type="int")
    enum NativeAnalog {
        LStick,
        RStick,
        NumAnalogs,
    }

    @Backing(type="int")
    enum NativeTrigger {
       LTrigger,
       RTrigger,
       NumTriggers,
    }

    parcelable GameDir {
        String path;
        boolean deep_scan;
    }

    parcelable PlayerInput {
        boolean connected;
        ControllerType controller_type;
        String[NativeButton.NumButtons] buttons;
        String[NativeAnalog.NumAnalogs] analogs;
        String[NativeTrigger.NumTriggers] motions;
        boolean vibration_enabled;
        int vibration_strength;
        int body_color_left;
        int body_color_right;
        int button_color_left;
        int button_color_right;
        String profile_name;
        boolean use_system_vibrator;
    }

    parcelable OverlayControlData {
       String id;
       boolean enabled;
       double landscape_position_x;
       double landscape_position_y;
       double portrait_position_x;
       double portrait_position_y;
       double foldable_position_x;
       double foldable_position_y;
    }

    parcelable Patch {
        boolean enabled;
        String name;
        String version;
        PatchType type;
        long program_id;
        long title_id;
    }

    parcelable RomMetadata {
        String title;
        long programId;
        String developer;
        String version;
        byte[] icon;
        boolean isHomebrew;
    }

    void NativeLibrary_setAppDirectory(String directory);
    int NativeLibrary_installFileToNand(String filename);
    boolean NativeLibrary_doesUpdateMatchProgram(long programId, String updatePath);
    void NativeLibrary_initializeGpuDriver(String hookLibDir, String customDriverDir, String customDriverName, String fileRedirectDir);
    boolean NativeLibrary_reloadKeys();
    void NativeLibrary_initializeSystem(boolean reload);
    long NativeLibrary_run(String path, int programIndex, boolean frontendInitiated);
    void NativeLibrary_surfaceChanged(int width, int height);
    void NativeLibrary_surfaceDestroyed();
    void NativeLibrary_unpauseEmulation();
    void NativeLibrary_pauseEmulation();
    void NativeLibrary_stopEmulation();
    boolean NativeLibrary_isRunning();
    boolean NativeLibrary_isPaused();
    double[] NativeLibrary_getPerfStats();
    String NativeLibrary_getCpuBackend();
    String NativeLibrary_getGpuDriver();
    void NativeLibrary_applySettings();
    void NativeLibrary_logSettings();
    void NativeLibrary_logDeviceInfo();
    void NativeLibrary_submitInlineKeyboardText(String text);
    void NativeLibrary_submitInlineKeyboardInput(int key_code);
    void NativeLibrary_initializeEmptyUserDirectory();
    String NativeLibrary_getAppletLaunchPath(long id);
    void NativeLibrary_setCurrentAppletId(int appletId);
    void NativeLibrary_setCabinetMode(int cabinetMode);
    boolean NativeLibrary_isFirmwareAvailable();
    Patch[] NativeLibrary_getPatchesForFile(String path, long programId);
    void NativeLibrary_removeUpdate(long programId);
    void NativeLibrary_removeDLC(long programId);
    void NativeLibrary_removeMod(long programId, String name);
    String[] NativeLibrary_verifyInstalledContents();
    int NativeLibrary_verifyGameContents(String path);
    String NativeLibrary_getSavePath(long programId);
    String NativeLibrary_getDefaultProfileSaveDataRoot(boolean future);
    void NativeLibrary_addFileToFilesystemProvider(String path);
    void NativeLibrary_clearFilesystemProvider();
    boolean NativeLibrary_areKeysPresent();
    void NativeLibrary_syncFileDescriptor(long addr);

    boolean NativeInput_isHandheldOnly();
    void NativeInput_onGamePadButtonEvent(String guid, int port, int buttonId, int action);
    void NativeInput_onGamePadAxisEvent(String guid, int port, int axis, float value);
    void NativeInput_onGamePadMotionEvent(String guid, int port, long deltaTimestamp, float xGyro, float yGyro, float zGyro, float xAccel, float yAccel, float zAccel);
    void NativeInput_onReadNfcTag(in byte[] data);
    void NativeInput_onRemoveNfcTag();
    void NativeInput_onTouchPressed(int fingerId, float xAxis, float yAxis);
    void NativeInput_onTouchMoved(int fingerId, float xAxis, float yAxis);
    void NativeInput_onTouchReleased(int fingerId);
    void NativeInput_onOverlayButtonEventImpl(int port, int buttonId, int action);
    void NativeInput_onOverlayJoystickEventImpl(int port, int stickId, float xAxis, float yAxis);
    void NativeInput_onDeviceMotionEvent(int port, long deltaTimestamp, float xGyro, float yGyro, float zGyro, float xAccel, float yAccel, float zAccel);
    void NativeInput_reloadInputDevices();
    String[] NativeInput_getInputDevices();
    void NativeInput_loadInputProfiles();
    String[] NativeInput_getInputProfileNames();
    boolean NativeInput_isProfileNameValid(String name);
    boolean NativeInput_createProfile(String name, int playerIndex);
    boolean NativeInput_deleteProfile(String name, int playerIndex);
    boolean NativeInput_loadProfile(String name, int playerIndex);
    boolean NativeInput_saveProfile(String name, int playerIndex);
    void NativeInput_loadPerGameConfiguration(int playerIndex, int selectedIndex, String selectedProfileName);
    void NativeInput_beginMapping(int type);
    String NativeInput_getNextInput();
    void NativeInput_stopMapping();
    void NativeInput_updateMappingsWithDefaultImpl(int playerIndex, String deviceParams, String displayName);
    String NativeInput_getButtonParamImpl(int playerIndex, int buttonId);
    void NativeInput_setButtonParamImpl(int playerIndex, int buttonId, String param);
    String NativeInput_getStickParamImpl(int playerIndex, int stickId);
    void NativeInput_setStickParamImpl(int playerIndex, int stickId, String param);
    int NativeInput_getButtonNameImpl(String param);
    int[] NativeInput_getSupportedStyleTagsImpl(int playerIndex);
    int NativeInput_getStyleIndexImpl(int playerIndex);
    void NativeInput_setStyleIndexImpl(int playerIndex, int styleIndex);
    boolean NativeInput_isControllerImpl(String params);
    boolean NativeInput_getIsConnected(int playerIndex);
    void NativeInput_connectControllersImpl(in boolean[] connected);
    void NativeInput_resetControllerMappings(int playerIndex);

    void NativeConfig_initializeGlobalConfig();
    void NativeConfig_unloadGlobalConfig();
    void NativeConfig_reloadGlobalConfig();
    void NativeConfig_saveGlobalConfig();
    void NativeConfig_initializePerGameConfig(long programId, String fileName);
    boolean NativeConfig_isPerGameConfigLoaded();
    void NativeConfig_savePerGameConfig();
    void NativeConfig_unloadPerGameConfig();
    boolean NativeConfig_getBoolean(String key, boolean needsGlobal);
    void NativeConfig_setBoolean(String key, boolean value);
    byte NativeConfig_getByte(String key, boolean needsGlobal);
    void NativeConfig_setByte(String key, byte value);
    char NativeConfig_getShort(String key, boolean needsGlobal);
    void NativeConfig_setShort(String key, char value);
    int NativeConfig_getInt(String key, boolean needsGlobal);
    void NativeConfig_setInt(String key, int value);
    float NativeConfig_getFloat(String key, boolean needsGlobal);
    void NativeConfig_setFloat(String key, float value);
    long NativeConfig_getLong(String key, boolean needsGlobal);
    void NativeConfig_setLong(String key, long value);
    String NativeConfig_getString(String key, boolean needsGlobal);
    void NativeConfig_setString(String key, String value);
    boolean NativeConfig_getIsRuntimeModifiable(String key);
    String NativeConfig_getPairedSettingKey(String key);
    boolean NativeConfig_getIsSwitchable(String key);
    boolean NativeConfig_usingGlobal(String key);
    void NativeConfig_setGlobal(String key, boolean global);
    boolean NativeConfig_getIsSaveable(String key);
    String NativeConfig_getDefaultToString(String key);
    GameDir[] NativeConfig_getGameDirs();
    void NativeConfig_setGameDirs(in GameDir[] dirs);
    void NativeConfig_addGameDir(in GameDir dir);
    String[] NativeConfig_getDisabledAddons(long programId);
    void NativeConfig_setDisabledAddons(long programId, in String[] disabledAddons);
    OverlayControlData[] NativeConfig_getOverlayControlData();
    void NativeConfig_setOverlayControlData(in OverlayControlData[] overlayControlData);
    PlayerInput[10] NativeConfig_getInputSettings(boolean global);
    void NativeConfig_setInputSettings(in PlayerInput[10] value, boolean global);
    void NativeConfig_saveControlPlayerValues();

    void Log_debug(String message);
    void Log_warning(String message);
    void Log_info(String message);
    void Log_error(String message);
    void Log_critical(String message);

    RomMetadata GameMetadata_getMetadata(String path, boolean reload);
    boolean GameMetadata_isValid(String path);
    void GameMetadata_resetMetadata();

    boolean GpuDriverHelper_supportsCustomDriverLoading();
    String[] GpuDriverHelper_getSystemDriverInfo(String hookLibPath);
}